package day0318.bigdecimal;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Author Stringzhua
 * @Date 2024/3/18 17:58
 * description:
 */
public class demo01 {
    public static void main(String[] args) {
        BigDecimal a1 = new BigDecimal("0.3");
        BigDecimal a2 = new BigDecimal("1.0");

        System.out.println("加"+a1.add(a2));
        System.out.println("减"+a1.subtract(a2));
        System.out.println("乘" + a1.multiply(a2));
//        System.out.println("除"+a1.divide(a2));//ArithmeticException 算术异常
        System.out.println("除" + a2.divide(a1, 2, RoundingMode.HALF_UP));

    }
}
